<template>
  <el-container>
  <el-aside :width="isCollapse?'65px': '200px'">
    <el-menu
      background-color="#353B4E"
      text-color="#fff"
      active-text-color="#ffd04b"
      :collapse="isCollapse"
      :collapse-transition=false>
            <el-menu-item index="1" :style="{width:isCollapse?'65px': '200px'}">
        <i class="el-icon-location"></i>
        <span slot="title">首页</span>
      </el-menu-item>
      <el-submenu index="2" :style="{width:isCollapse?'65px': '200px'}">
       <template slot="title">
          <i class="el-icon-menu"></i>
          <span>内容管理</span>
        </template>
        <el-menu-item index="1-1">发布文章</el-menu-item>
        <el-menu-item index="1-1">文章列表</el-menu-item>
        <el-menu-item index="1-1">评论列表</el-menu-item>
        <el-menu-item index="1-1">素材管理</el-menu-item>
      </el-submenu>
      <el-menu-item index="3" :style="{width:isCollapse?'65px': '200px'}">
        <i class="el-icon-location"></i>
        <span slot="title">粉丝管理</span>
      </el-menu-item>
      <el-menu-item index="4" :style="{width:isCollapse?'65px': '200px'}">
        <i class="el-icon-location"></i>
        <span slot="title">账户信息</span>
      </el-menu-item>
    </el-menu>
  </el-aside>
  <el-container>
    <el-header>
      <div id="lt">
         <i :class="isCollapse?'el-icon-s-unfold':'el-icon-s-fold'" @click="isCollapse=!isCollapse"></i>
         <span>江苏传智播客教育科技股份有限公司</span>
      </div>
      <div id="rt">
         <el-input type="text" placeholder="请输入搜索文章内容" style="width:234px"></el-input>
         <span style="margin:0 25px">消息</span>
         <el-dropdown trigger="click">
              <span class="el-dropdown-link">
                <img :src="photo" alt="" width="40px" height="40px" style="margin-right:10px">
               {{name}}
                <i class="el-icon-arrow-down el-icon--right"></i>
              </span>
          <el-dropdown-menu slot="dropdown">
              <el-dropdown-item>个人信息</el-dropdown-item>
              <el-dropdown-item>GitHub地址</el-dropdown-item>
              <el-dropdown-item @click.native="logout()">退出</el-dropdown-item>
          </el-dropdown-menu>
        </el-dropdown>
      </div>
    </el-header>
    <el-main>
      <router-view></router-view>
    </el-main>
  </el-container>
</el-container>
</template>

<script>
  export default {
    data(){
      return {
        isCollapse:false
      }
    },
    computed:{
      name(){
        return JSON.parse(window.sessionStorage.getItem('userinfo')).name
      },
      photo(){
        return JSON.parse(window.sessionStorage.getItem('userinfo')).photo
      }
    },
    methods:{
      //退出系统
      logout(){
         this.$confirm('确认要退出系统吗', '退出', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
        //清空sessionStorage
        window.sessionStorage.clear()
        //导航到登录界面
        this.$router.push('/login')
        }).catch(() => {
                   
        });
   
      }
    }
}
</script>

<style lang="less" scoped>
.el-container{
  height: 100%;
  .el-aside{
    background-color:#353B4E;
  }
  .el-header{
    background-color: #fff;
    display: flex;
    justify-content: space-between;
    padding: 0 9px 0 10px;
    min-width: 800px;
    #lt{
      height: 100%;
      width: 40%;
      // background-color: lightblue;
      display: flex;
      align-items: center;
      font-size: 20px;
    }
    #rt{
      height: 100%;
      width: 50%;
      // background-color: lightpink;
      display: flex;
      justify-content: flex-end;
      align-items: center;
      .el-dropdown-link{
        display: flex;
        align-items: center;
        height: 100%;
      }
    }
  }
  .el-main{
    background-color: #999;
  }
}
</style>
